﻿Public Class frmMedicos

    Private codmedico As String
    Private nomMedico As String

    'Dim conexion As String = "Data Source=JOSE-PC\SQLEXPRESS;Initial Catalog=BTTbd;Persist Security Info=True;User ID=BTTadmin;Password=admin"
    Dim bd As New BTTbdDataContext

    Private Sub btnSeleccionar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSeleccionar.Click
        

        codmedico = dgvPersonal.CurrentRow.Cells("codigo").Value
        nomMedico = dgvPersonal.CurrentRow.Cells("nombre").Value.ToString _
                     + " " + dgvPersonal.CurrentRow.Cells("apepat").Value.ToString _
                     + " " + dgvPersonal.CurrentRow.Cells("apemat").Value.ToString

        Me.Close()

    End Sub

    Private Sub frmMedicos_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Dim medicos = From medico In bd.personals _
                      Where medico.id_cargo = "1" _
                      Select medico


        Me.PersonalBindingSource.DataSource = medicos


    End Sub


    Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click

        Try
            bd.SubmitChanges()
            MsgBox("Saved")
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try

    End Sub

    Public Property _codMedico()
        Get
            Return codmedico
        End Get
        Set(ByVal value)
            Me.codmedico = value
        End Set
    End Property

    Public Property _nomMedico()
        Get
            Return nomMedico
        End Get
        Set(ByVal value)
            Me.nomMedico = value
        End Set
    End Property

End Class